package edu.szte.ovrt.datahandler.test;

import edu.szte.ovrt.datahandler.model.*;

public class ModelFactory {
	public static final String DOCUMENT_FULL_XML = "" + //
			"<?xml version=\"1.0\" encoding=\"utf-8\"?>" //
			+ "<Document xmlns=\"http://www.inf.u-szeged.hu/ovrt/2009-2010-1/datahandler\">" //
			+ "<Section name=\"Empty section\"></Section>" //
			+ "<Section name=\"Section with one item\">" //
			+ "<Item key=\"Key\" value=\"Value\"></Item>" //
			+ "</Section>" //
			+ "<Section name=\"Section with more items\">" //
			+ "<Item key=\"key1\" value=\"value1\"></Item>" //
			+ "<Item key=\"key2\" value=\"value2\"></Item>" //
			+ "<Item key=\"key3\" value=\"value3\"></Item>" //
			+ "</Section>" //
			+ "</Document>";
	public static final String DOCUMENT_EMPTY_XML = "" + //
			"<?xml version=\"1.0\" encoding=\"utf-8\"?>" //
			+ "<Document xmlns=\"http://www.inf.u-szeged.hu/ovrt/2009-2010-1/datahandler\">" //
			+ "</Document>";
	public static final String DOCUMENT_ONE_SECTION_XML = "" + //
			"<?xml version=\"1.0\" encoding=\"utf-8\"?>" //
			+ "<Document xmlns=\"http://www.inf.u-szeged.hu/ovrt/2009-2010-1/datahandler\">" //
			+ "<Section name=\"Section with one item\">" //
			+ "<Item key=\"Key\" value=\"Value\"></Item>" //
			+ "</Section>" //
			+ "</Document>";

	public static Document createDocumentEmpty() {
		return new Document();
	}

	public static Document createDocumentWithOneSection() {
		final Document document = new Document();
		final Section sectionWithOneItem = createSectionWithOneItem(document);
		document.addSection(sectionWithOneItem);
		return document;
	}

	public static Document createDocumentFull() {
		final Document document = new Document();
		final Section sectionEmpty = createSectionEmpty(document);
		document.addSection(sectionEmpty);
		final Section sectionWithOneItem = createSectionWithOneItem(document);
		document.addSection(sectionWithOneItem);
		final Section sectionWithMoreItems = createSectionWithMoreItems(document);
		document.addSection(sectionWithMoreItems);
		return document;
	}

	public static Section createSectionEmpty(final Document document) {
		return new Section(document, "Empty section");
	}

	public static Section createSectionWithOneItem(final Document document) {
		final Section oneItemSection = new Section(document, "Section with one item");
		oneItemSection.addItem(createItem(oneItemSection));
		return oneItemSection;
	}

	public static Section createSectionWithMoreItems(final Document document) {
		final Section moreItemSection = new Section(document, "Section with more items");
		moreItemSection.addItem(createItem1(moreItemSection));
		moreItemSection.addItem(createItem2(moreItemSection));
		moreItemSection.addItem(createItem3(moreItemSection));
		return moreItemSection;
	}

	public static Item createItem(final Section parent) {
		return new Item(parent, "Key", "Value");
	}

	public static Item createItem1(final Section parent) {
		return new Item(parent, "key1", "value1");
	}

	public static Item createItem2(final Section parent) {
		return new Item(parent, "key2", "value2");
	}

	public static Item createItem3(final Section parent) {
		return new Item(parent, "key3", "value3");
	}
}
